<template>
	<view class="content fofa">
		<tabnav title="实名认证" :col="back"></tabnav>
		<view style="height: 90rpx;"></view>
		<view class="textCen">
			<image src="https://www.sign.run/applet/static/wode/yxImage.png" style="width: 141rpx;height: 117rpx;"></image>
		</view>
		<!-- <view class="textCen foSi35" style="margin-top: 53rpx;">十米</view> -->
		<view class="wid80 mar " style="margin-top: 65rpx;">
			<view class="foSi30" style="">真实姓名</view>
			<input class="wid100 hei80 mar-top10" v-model="nickname" placeholder="请输入真实姓名"/>
			<view class="wid100 xia"></view>
			<view class="wid100 xia"></view>
		</view>
		<view class="wid80 mar " style="margin-top: 65rpx;">
			<view class="foSi30" style="">身份证号码</view>
			<input class="wid100 hei80 mar-top10" v-model="id_number" placeholder="请输入身份证号码"/>
			<view class="wid100 xia"></view>
			<view class="wid100 xia"></view>
		</view>
		<view class="wid80 mar dis disAl disJuC coFFF foSi35 borRad10" :style="'background-color: '+back+';'"
		 style="margin-top: 71rpx;height: 91rpx;" @click="submit_to">提交</view>
	</view>
</template>

<script>
	import tabnav from "../../common/tabnav/tabnav.vue"
	export default {
		components: {
			tabnav,
		},
		data() {
			return {
				
				back: uni.getStorageSync('back'),
				nickname:'',
				id_number:''
			}
		},
		onLoad() {
			
		},
		methods: {
			submit_to(){
				var that = this
				if(!that.checkIdCard(that.id_number)){
					return uni.showToast({
						title:'身份证错误'
					})
				}
				if(!that.checkName(that.nickname)){
					return uni.showToast({
						title:'姓名错误'
					})
				}
				uni.showLoading({
					title:'加载中...'
				})
				uni.request({
					url: that.global.url+'api/qianyu_dzq/applet_user_up_nickname_id_number',
					method: 'POST',
					header:{'site-id':that.global.site_id,'token':uni.getStorageSync('inuse_userinfo_token')},
					data: {
						nickname:that.nickname,
						id_number:that.id_number
					},
					success(res) {
					    let result = res.data
						if(result.code == 1){
							uni.showToast({
								title:result.msg,
								icon:'success'
							})
							setTimeout(()=>{
								uni.navigateBack()
							},1000)
						}else{
							uni.showToast({
								title:result.msg,
								icon:'error'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
			// 验证身份证号码正确性
			checkIdCard(idCard) {
			  const reg = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/;
			  return reg.test(idCard);
			},
			 
			// 验证姓名正确性
			checkName(name) {
			  const reg = /^[\u4e00-\u9fa5]{2,10}$/; // 2到10个中文字符
			  return reg.test(name);
			},
			
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				});
			}
			
		}
	}
</script>

<style>
	.content {}
	.xia{
		height: 1rpx;
		background: #BFBFBF;
	}
</style>
